package com.example.myapplication;

import android.graphics.Color;
import android.os.Build;
import android.os.Bundle;
import android.widget.Button;
import android.widget.TextView;

import androidx.annotation.RequiresApi;

import java.lang.reflect.Field;

public class ModifiedActivity extends OriginalActivity {

    @Override
    protected void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
        try {
            Field field = OriginalActivity.class.getDeclaredField("button2");
            field.setAccessible(true);
            Button button = (Button) field.get(this);
            button.setText("修改后按钮");
            button.setBackgroundColor(Color.parseColor("#FFB6C1"));
        } catch (NoSuchFieldException | IllegalAccessException e) {
            e.printStackTrace();
        }
    }
}